/**
XenSim simulates xenbal.
Copyright (C) 2006 Travis Vachon

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
package xensim;

import java.util.Vector;



public class SimulatorTest extends junit.framework.TestCase {
	
	private static long second = 1000;
	private static long minute = 60*second;
	private static long PAGE_SIZE = 4 * SimGlobals.KB;
	private static long BANDWIDTH = 1 * SimGlobals.Gb;
	

	public void testEventQueue() throws ConfigurationError{
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		Simulator sim = new Simulator(2*second,globals);
		globals.eventQueue.add(new PrintEvent(1000, "event 2"));
		globals.eventQueue.add(new PrintEvent(500, "event 1"));
		globals.eventQueue.add(new PrintEvent(1500, "event 3"));
		
		sim.run();
		
		assertTrue(globals.eventQueue.size() == 0);
	}
	
	
	public void testSimpleRun() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 60*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);

		Vector<Domain> domains = new Vector<Domain>();
		
		Domain domain1 = new Domain(globals, "dom1", 400 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.1),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		node1.bootDomain(domain1);
		domains.add(domain1);
		
		Domain domain2 = new Domain(globals, "dom2", 400 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.2),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain2);
		domains.add(domain2);
		
		Domain domain3 = new Domain(globals, "dom3", 400 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.2),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain3);
		domains.add(domain3);
		System.out.println(node1.numberOfDomains());
		System.out.println(domains.size());
		
		assertTrue(node1.numberOfDomains() == domains.size() + 1);
		
		Monitor monitor = new Monitor(globals, "testSimple.log");
		
		
		sim.run();
				
		
		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		
		
//		assertTrue(node2.domains.size() == 1);
		
		
	}
	
	public void testCantRun() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 60*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, (long)(1.5 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);

		Vector<Domain> domains = new Vector<Domain>();
		
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.1),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		node1.bootDomain(domain1);
		domains.add(domain1);
		
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.2),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain2);
		domains.add(domain2);
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(domain1.isActive());
		assertFalse(domain2.isActive());
		
		
		sim.run();
				
		
		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		
		
//		assertTrue(node2.domains.size() == 1);
		
		
	}

	
	public void testSimpleMigrate() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 10*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain);
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 1);
		

		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain, node2));

		sim.run();
		System.out.println("AAA" + node1.numberOfDomains());
		System.out.println("AAA" + node2.numberOfDomains());
		assertTrue(node1.numberOfDomains() == 1);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);

		// assertTrue(node2.domains.size() == 1);

	}
	
	public void testSimpleMigrateLB() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 10*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH/10,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH/10,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain);
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 1);
		

		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain, node2));

		sim.run();

		assertTrue(node1.numberOfDomains() == 1);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);

		// assertTrue(node2.domains.size() == 1);

	}
	
	public void testCantMigrate() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 10*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, (long)(1.5 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain1);
		
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node2.bootDomain(domain2);
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);
		
		Monitor monitor = new Monitor(globals, "test1.log");

		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));

		sim.run();

		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);

		// assertTrue(node2.domains.size() == 1);

	}
	
	
	
	public void testMigrate2() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 10*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain1);
		node2.bootDomain(domain2);
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);
		
		Monitor monitor = new Monitor(globals, "test2.log");

		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute, node2, domain2, node1));

		sim.run();

		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);

		// assertTrue(node2.domains.size() == 1);

	}
	
	public void testMigrate3() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 10*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, (long)(1.5 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain1);
		node1.bootDomain(domain2);
		
		assertTrue(node1.numberOfDomains() == 3);
		assertTrue(node2.numberOfDomains() == 1);
		
		Monitor monitor = new Monitor(globals, "test3.log");
		
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute + 30*second, node2, domain2, node1));

		sim.run();

		
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);



	}

	public void testMigrate4() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 20*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 1 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, (long)(1.5 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain1);
		
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 1);
		
		Monitor monitor = new Monitor(globals, "test4.log");
		
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));
		globals.eventQueue.add(new BootEvent(10*minute,node1,domain2));

		sim.run();

		
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 2);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);



	}
	public void testMigrate5() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 20*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 5 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, 5* SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain2 = new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain3 = new Domain(globals, "dom3", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain4 = new Domain(globals, "dom4", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		Domain domain5 = new Domain(globals, "dom5", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
		
		node1.bootDomain(domain1);
		node1.bootDomain(domain2);
		node1.bootDomain(domain3);
		node1.bootDomain(domain4);
		node1.bootDomain(domain5);
		
		
		
		assertTrue(node1.numberOfDomains() == 6);
		assertTrue(node2.numberOfDomains() == 1);
		
		
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain2, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain3, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain4, node2));
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain5, node2));
		
		Monitor monitor = new Monitor(globals, "test5.log");

		sim.run();

		
		
		assertTrue(node1.numberOfDomains() == 1);
		assertTrue(node2.numberOfDomains() == 6);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);



	}
	
	public void testMigrate6() throws ConfigurationError {
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 60*minute;
		Simulator sim = new Simulator(runtime, globals);
		Node node1 = new Node(globals, "node1", 2000, 1 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		Node node2 = new Node(globals, "node2", 2000, (long)(1.5 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0));
		nodes.add(node1);
		nodes.add(node2);
		Domain domain1 = new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb));
				
		node1.bootDomain(domain1);
		
		Monitor monitor = new Monitor(globals, "test6.log");
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 1);
		
		
		globals.eventQueue.add(new MigrationEvent(1*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(4*minute, node2, domain1, node1));
		globals.eventQueue.add(new MigrationEvent(7*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(10*minute, node2, domain1, node1));
		globals.eventQueue.add(new MigrationEvent(13*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(16*minute, node2, domain1, node1));
		globals.eventQueue.add(new MigrationEvent(19*minute, node1, domain1, node2));
		globals.eventQueue.add(new MigrationEvent(22*minute, node2, domain1, node1));
		
		

		sim.run();

		
		
		assertTrue(node1.numberOfDomains() == 2);
		assertTrue(node2.numberOfDomains() == 1);

		System.out.println(node1.idleTime);
		System.out.println(((double)node1.idleTime)/runtime);
		System.out.println(node2.idleTime);
		System.out.println(((double)node2.idleTime)/runtime);



	}
	
	public void testMigrate7() throws ConfigurationError{
		Vector<Node> nodes = new Vector<Node>();
		SimGlobals globals = new SimGlobals(nodes);
		long runtime = 60*minute;
		Simulator sim = new Simulator(runtime, globals);
		nodes.add(new Node(globals, "node1", 2000, 2 * SimGlobals.GB,
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0)));
		nodes.add(new Node(globals, "node2", 2000, (long)(2 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0)));
		nodes.add(new Node(globals, "node3", 2000, (long)(2 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0)));
		nodes.add(new Node(globals, "node4", 2000, (long)(2 * SimGlobals.GB),
				PAGE_SIZE, BANDWIDTH,0,	new ConstRateFn(0), new TwoGhzConstFn(0),	new ConstNetworkFn(0)));
		
		Vector<Domain> domains = new Vector<Domain>();
		domains.add(new Domain(globals, "dom1", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb)));
		domains.add(new Domain(globals, "dom2", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb)));
		domains.add(new Domain(globals, "dom3", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb)));
		domains.add(new Domain(globals, "dom4", 800 * SimGlobals.MB,
				new ConstRateFn(0.005), new TwoGhzConstFn(0.9),
				new ConstNetworkFn(10 * SimGlobals.Kb)));
		nodes.get(0).bootDomain(domains.get(0));
		nodes.get(1).bootDomain(domains.get(1));
		nodes.get(2).bootDomain(domains.get(2));
		nodes.get(2).bootDomain(domains.get(3));
		
		assertTrue(nodes.get(0).numberOfDomains() == 2);
		assertTrue(nodes.get(1).numberOfDomains() == 2);
		assertTrue(nodes.get(2).numberOfDomains() == 3);
		assertTrue(nodes.get(3).numberOfDomains() == 1);
		
		Monitor monitor = new Monitor(globals, "test7.log");
		for (Node node:nodes){
			globals.eventQueue.add(new BalanceEventSI(1*SimGlobals.TIME_CONSTANT,globals,monitor,node));
		}
		sim.run();
		
		
		assertTrue(nodes.get(0).numberOfDomains() == 2);
		assertTrue(nodes.get(1).numberOfDomains() == 2);
		assertTrue(nodes.get(2).numberOfDomains() == 2);
		assertTrue(nodes.get(3).numberOfDomains() == 2);
		
	}
	
	
	public static void main(String[] args) throws ConfigurationError{
		SimulatorTest tester = new SimulatorTest();
		tester.testMigrate7();
		
	}
	
	
}
